//part1:C03:ex3.36.cpp -- compare two arrays.
#include <iostream>
#include <ctime>
#include <cstdlib>

int main(void)
{
    using namespace std;
    const int sz = 5;
    int a[sz], b[sz], i;
    srand((unsigned)time(NULL));
    for (int i = 0; i < sz; ++i)
    {
        a[i] = rand() % 10;    
    }
    cout << "Datas had generated.\nEnter 5 integers(0~9),"
        "could include repeated.\n";
    int uVal;
    for (int i = 0; i < sz; ++i)
    {
        if (cin >> uVal)    
        {
            b[i] = uVal;
        }
    }
    cout << "Data is :\n";
    for (auto val : a)
    {
        cout << val << " ";    
    }
    cout << endl;
    cout << "you answer is:" << endl;
    for (auto val : b)
    {
        cout << val << " ";    
    }
    cout << endl;
    int *pa = begin(a);
    int *pb = begin(b);
    while (pa != end(a) && pb != end(b))
    {
        if (*pa != *pb)
        {
            cout << "you answer is wrong!\nTwo array are not equal!\n";
            return -1;
        }
        pa++;
        pb++;
    }
    cout << "congratulation!" << endl; 

    return 0;
}
